package com.example.doctorstation.POJOController;
import com.example.doctorstation.Config.MyResponse;
import com.example.doctorstation.POJOData.Drug;
import com.example.doctorstation.POJOData.Frequency;
import com.example.doctorstation.POJOData.Usage;
import com.example.doctorstation.POJOMapper.CatalogDictionaryMapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;

@RestController
public class CatalogDictionaryController {
    //注入UserMapper 这里DEA可能会提示报错不用理会就行
    @Resource
    CatalogDictionaryMapper catalogDictionaryMapper;

    @GetMapping("/drug")
    public MyResponse findAllDrug() {
        try {
            return MyResponse.success("获取药品目录！", catalogDictionaryMapper.findAllDrug());
        } catch (Throwable e) {
            e.printStackTrace();
            return MyResponse.error("没有药品目录数据");
        }
    }

    @GetMapping("/frequency")
    public MyResponse findAllFrequency() {
        try {
            return MyResponse.success("获取用药频次目录！", catalogDictionaryMapper.findAllFrequency());
        } catch (Throwable e) {
            e.printStackTrace();
            return MyResponse.error("没有用药频次目录数据");
        }
    }

    @GetMapping("/usage")
    public MyResponse findAllUsage() {
        try {
            return MyResponse.success("获取用药用法目录！", catalogDictionaryMapper.findAllUsage());
        } catch (Throwable e) {
            e.printStackTrace();
            return MyResponse.error("没有用药用法目录数据");
        }
    }
}